﻿using System;
using System.Collections.Generic;
using System.Text;
using Watchdog.Bll.Factory;

namespace Watchdog.Bll.Base {

    public partial class TargetDeviceBase {

        #region [ Local variables ]
        Facade.TargetDevice intdata;
        #endregion

        #region [ Constructor(s) ]
        internal TargetDeviceBase () {
            intdata = new Watchdog.Facade.TargetDevice ();
        }
        internal TargetDeviceBase (Facade.TargetDevice targetdevice) : base () {
            intdata = targetdevice;
        }
        #endregion

        #region [ Field Properties ]
        public int Test {
            get { return intdata.Test; }
        }
        public int Device {
            get { return intdata.Device; }
        }
		#endregion
		
        #region [ Data Methods ]
        public void Update () {
            if (Test == -1)
                TargetDeviceFactory.Insert ( this );
            else
                TargetDeviceFactory.Update ( this );
        }

        public void Delete () {
            TargetDeviceFactory.Delete ( this );
        }
        #endregion

		#region [ Many to many relations native type ]

		#endregion

		#region [ Add & Remove methods for many to many relations native type ]

		#endregion
		
        internal Facade.TargetDevice IntData {
            get { return intdata; }
            set { intdata = value; }
        }

        #region [ Equality ]
        public override int GetHashCode () {
            return Test;
        }
        public static bool operator == ( TargetDeviceBase lt1, TargetDeviceBase lt2 ) {
            if (System.Object.ReferenceEquals ( lt1, lt2 ))
                return true;

            if ((object)lt1 == null || (object)lt2 == null)
                return false;
            return lt1.Equals ( lt2 );
        }
        public static bool operator != ( TargetDeviceBase lt1, TargetDeviceBase lt2 ) {
            if (lt1 == null || lt2 == null)
                return false;
            return !(lt1 == lt2);
        }

        public override bool Equals ( object obj ) {
            if (!(obj is TargetDeviceBase))
                return false;
            return (this.CompareTo ( obj ) == 0);
        }

        private int CompareTo ( object obj ) {
            if (!(obj is TargetDeviceBase)) {
                throw new ArgumentException ( "A 'TargetDeviceBase' object is required for comparison." );
            }
            return this.Test.CompareTo ( ((TargetDeviceBase)obj).Test );
        }
        #endregion

	}
}
